Imports System.Data.OleDb
Imports DTO

Public Class LopHocDao
    Inherits AbstractDao
    Public Sub New()

    End Sub
    Public Function LayDanhSach() As IList
        Dim ds As New ArrayList()
        Dim cn As OleDbConnection
        Dim strSQL As String
        'B1 & B2: Tao chuoi ket noi, mo ket noi bang doi tuong ket noi
        cn = ConnectionData()
        'B3: Tao chuoi strSQL thao tac CSDL
        strSQL = "Select * From LopHoc"
        'B4: Thuc thi chuoi strSQL
        Dim cmd As New OleDbCommand(strSQL, cn)
        Dim dr As OleDbDataReader
        dr = cmd.ExecuteReader()
        Dim lh As New LopHocDto()
        While (dr.Read())
            lh = New LopHocDto()
            lh.Ma = dr("Ma")
            lh.Ten = dr("Ten")
            ds.Add(lh)
        End While
        'B5: Dong ket noi CSDL
        cn.Close()
        Return ds
    End Function
End Class
